﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Web.Services;
using BLL;
using Newtonsoft.Json;
using Model;

namespace PropertyAppraisal
{
    public partial class Index1 : System.Web.UI.Page
    {
        private static AuthorityAndRolesBll arBll = new AuthorityAndRolesBll();

          
        protected void Page_Load(object sender, EventArgs e)
        {
              rid=Convert.ToInt32(Session["id"]);
        }
        private static int rid;
      
        /// <summary>
        /// 父级节点
        /// </summary>
        /// <returns></returns>
        [WebMethod]
        public static string Partent()
        {
            int Roid = rid;
            var Partent = arBll.Show().Where(m => m.parentId == 0 && m.roles_Id == Roid).ToList();
          
            
            //foreach (var tree in Partent)
            //{
            //    PartentId(tree.authority_Id);//调用子节点
            //}
            
            return JsonConvert.SerializeObject(Partent);
        }

        /// <summary>
        /// 子级节点
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [WebMethod]
        public static string PartentId(int id)
        {

            int Roid = rid;
            var zhi = arBll.Show().Where(m => m.parentId == id && m.roles_Id == Roid).ToList();
            return JsonConvert.SerializeObject(zhi);
        }
    }
}